package com.dhcc.controller;

import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.SendStatus;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rocketmq")
public class HelloRocketMqController {

	@Autowired
	private RocketMQTemplate rocketMQTemplate;
	
	/**
	 * 发送同步消息 第一个参数是目的地，格式是topic:tag
	 */
	@GetMapping("/sendSyncMsg")
	public String sendSyncMsg(String msg) {
		SendResult syncSend = rocketMQTemplate.syncSend("hello_springboot_rocketmq_topic", msg);
		return syncSend.getSendStatus().toString();
	}
}
